
interface UseThrottleProps {
  callback: (e: any) => void,
  time?: number
}

export const useThrottle = ({ callback, time = 500 }: UseThrottleProps) => {
  var timer: any = null;
  return (e:any) => {
    if (timer) return;
    timer = setTimeout(() => {
      callback(e)
      timer = null;
    }, time)
  }
}
